package Interfaz;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;


/**
 * CU005 - Modificar competencia deportiva (modalidad Liga)
 * @author 
 */
public class CU005_liga {

	protected Shell shlNueva_liga;
	private Text text;
	private Text text_1;
	private Text text_2;
	private Text text_3;
	private Text text_4;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			CU005_liga window = new CU005_liga();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		
		// Centrar ventana
		Monitor primary = display.getPrimaryMonitor();
		Rectangle bounds = primary.getBounds();
		Rectangle rect = shlNueva_liga.getBounds();
		int x = bounds.x + (bounds.width - rect.width) / 2;
		int y = bounds.y + (bounds.height - rect.height) / 2;	    
		shlNueva_liga.setLocation(x, y);
		
		Label lblNewLabel = new Label(shlNueva_liga, SWT.NONE);
		lblNewLabel.setBounds(10, 23, 103, 15);
		lblNewLabel.setText("Puntos por victoria:");
		
		text = new Text(shlNueva_liga, SWT.BORDER);
		text.setBounds(119, 20, 76, 21);

		final Label lblPuntosPorEmpate = new Label(shlNueva_liga, SWT.NONE);
		lblPuntosPorEmpate.setEnabled(false);
		lblPuntosPorEmpate.setText("Puntos por empate:");
		lblPuntosPorEmpate.setBounds(170, 64, 103, 15);
		
		text_1 = new Text(shlNueva_liga, SWT.BORDER);
		text_1.setEnabled(false);
		text_1.setBounds(279, 61, 76, 21);
		
		final Button btnEmpatePermitido = new Button(shlNueva_liga, SWT.CHECK);
		btnEmpatePermitido.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				lblPuntosPorEmpate.setEnabled(btnEmpatePermitido.getSelection());
				text_1.setEnabled(btnEmpatePermitido.getSelection());
			}
		});
		btnEmpatePermitido.setBounds(10, 63, 116, 16);
		btnEmpatePermitido.setText("Empate permitido");
		
		Label lblPuntosPorPresentarse = new Label(shlNueva_liga, SWT.NONE);
		lblPuntosPorPresentarse.setText("Puntos por presentarse:");
		lblPuntosPorPresentarse.setBounds(10, 103, 124, 15);
		
		text_2 = new Text(shlNueva_liga, SWT.BORDER);
		text_2.setBounds(140, 100, 76, 21);
		
		Label lblNewLabel_1 = new Label(shlNueva_liga, SWT.NONE);
		lblNewLabel_1.setBounds(10, 143, 116, 15);
		lblNewLabel_1.setText("Forma de puntuaci\u00F3n:");
		
		final Label lblCantidadMxima = new Label(shlNueva_liga, SWT.NONE);
		lblCantidadMxima.setEnabled(false);
		lblCantidadMxima.setText("Cantidad m\u00E1xima:");
		lblCantidadMxima.setBounds(140, 171, 96, 15);
		
		text_3 = new Text(shlNueva_liga, SWT.BORDER);
		text_3.setEnabled(false);
		text_3.setBounds(242, 168, 76, 21);
		
		final Label lblPuntosPorAusencia = new Label(shlNueva_liga, SWT.NONE);
		lblPuntosPorAusencia.setEnabled(false);
		lblPuntosPorAusencia.setText("Puntos por ausencia:");
		lblPuntosPorAusencia.setBounds(140, 211, 110, 15);
		
		text_4 = new Text(shlNueva_liga, SWT.BORDER);
		text_4.setEnabled(false);
		text_4.setBounds(256, 208, 76, 21);
		
		final Button btnSets = new Button(shlNueva_liga, SWT.RADIO);
		btnSets.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				lblCantidadMxima.setEnabled(true);
				text_3.setEnabled(true);
				lblPuntosPorAusencia.setEnabled(false);
				text_4.setEnabled(false);
			}
		});
		btnSets.setBounds(10, 170, 42, 16);
		btnSets.setText("Sets");
		
		Button btnPuntuacin = new Button(shlNueva_liga, SWT.RADIO);
		btnPuntuacin.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				lblCantidadMxima.setEnabled(false);
				text_3.setEnabled(false);
				lblPuntosPorAusencia.setEnabled(true);
				text_4.setEnabled(true);
			}
		});
		btnPuntuacin.setBounds(10, 210, 90, 16);
		btnPuntuacin.setText("Puntuaci\u00F3n");
		
		Button button = new Button(shlNueva_liga, SWT.NONE);
		button.setText("Cancelar");
		button.setBounds(315, 267, 108, 32);
		
		Button btnFinalizar = new Button(shlNueva_liga, SWT.NONE);
		btnFinalizar.setText("Guardar");
		btnFinalizar.setBounds(183, 267, 108, 32);
		
		Button button_1 = new Button(shlNueva_liga, SWT.NONE);
		button_1.setText("<< Anterior");
		button_1.setBounds(51, 267, 108, 32);
		
		shlNueva_liga.open();
		shlNueva_liga.layout();
		while (!shlNueva_liga.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shlNueva_liga = new Shell(SWT.CLOSE | SWT.TITLE | SWT.MIN);
		shlNueva_liga.setMinimumSize(new Point(132, 28));
		shlNueva_liga.setSize(450, 347);
		shlNueva_liga.setText("Modalidad Liga");

	}
}
